package cn.itsource.org.domain;

import cn.itsource.basic.domain.BaseTreeNode;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;

import javax.persistence.*;
import javax.validation.constraints.NotBlank;
import javax.validation.constraints.Size;

@Data
@AllArgsConstructor
@NoArgsConstructor
@Table(name = "t_department")
@ApiModel(value = "部门对象", description = "部门对象参数")
public class Department extends BaseTreeNode<Department> {
    @Id
    //返回自增长的id给你
    @GeneratedValue(strategy = GenerationType.IDENTITY)
    @ApiModelProperty(value = "部门ID")
    private Long id;

    @ApiModelProperty(value = "部门编号")
    @Size(min = 3, max = 8, message = "部门编号必须在3-8位之间(✺ω✺)")
    private String sn;

    @ApiModelProperty(value = "部门名称")
    @NotBlank(message = "部门名称不能为空(*╹▽╹*)")
    private String name;

    @ApiModelProperty(value = "部门启用状态")
    private Integer state;

    @ApiModelProperty(value = "部门经理id")
    @Column(name = "manager_id")
    private Long managerId;

    @ApiModelProperty(value = "父部门id")
    @Column(name = "parent_id")
    private Long parentId;

    @Column(name = "dir_path")
    private String dirPath;


    /**
     * 临时字段
     * 配置这个注解,这个字段不参与表的curd了
     */
    @Transient
    private Employee manager;

    @Transient
    private Department parent;

    @Transient
    private Long[] parentIds;
}
